//
//  LeftCollectionViewCell.m
//  Daybook
//
//  Created by liutaifeng on 16/5/23.
//  Copyright © 2016年 zhangbin. All rights reserved.
//

#import "LeftCollectionViewCell.h"

@interface LeftCollectionViewCell ()
@property (nonatomic, strong) UIImageView *picImageView;
@property (nonatomic, strong) UILabel *detailLabel;

@end


@implementation LeftCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}
- (void)createView {
    self.model = [[AccountBookModel alloc] init];
    self.picImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:_picImageView];
    
    self.detailLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_detailLabel];
    
    self.bottomView = [[UIView alloc] init];
    [self.contentView addSubview:_bottomView];
    
    self.deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [_bottomView addSubview:_deleteButton];
    
    self.setButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [_bottomView addSubview:_setButton];
    
    self.markImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:_markImageView];
//    _markImageView.backgroundColor = [UIColor whiteColor];

}
- (void)layoutSubviews {
    [super layoutSubviews];
    _picImageView.frame = self.contentView.frame;
    _detailLabel.frame = CGRectMake(self.contentView.frame.size.width / 5, 10, self.contentView.frame.size.width / 5 * 4 - 10, self.contentView.frame.size.height / 5);
    _bottomView.frame = CGRectMake(0, self.contentView.frame.size.height - 50, _picImageView.frame.size.width, 50);
    _bottomView.layer.cornerRadius = 3;
    _bottomView.layer.masksToBounds = YES;
    _deleteButton.frame = CGRectMake(13, 5, 35, 35);
    _setButton.frame = CGRectMake(_bottomView.frame.size.width - 48, 5, 35, 35);
    
    _markImageView.frame = CGRectMake(0, 0, 40, 40);
    _markImageView.center = self.contentView.center;
}
- (void)setModel:(AccountBookModel *)model {
    if (_model != model) {
        _model = model;
        _picImageView.image = [UIImage imageNamed:_model.accountBookCover];
        _detailLabel.text = _model.accountBookName;
        _detailLabel.textAlignment = NSTextAlignmentRight;
        _detailLabel.font = [UIFont systemFontOfSize:20];
        _detailLabel.textColor = [UIColor whiteColor];
        _bottomView.backgroundColor = [UIColor whiteColor];
        _bottomView.alpha = 0.5;
        [_deleteButton setImage:[UIImage imageNamed:@"shanchu.png"] forState:UIControlStateNormal];
        
        [_setButton setImage:[UIImage imageNamed:@"shezhi.png"] forState:UIControlStateNormal];
        
//        _markImageView.backgroundColor = [UIColor redColor];
        _markImageView.image = [UIImage imageNamed:@"gouxuanLightGray_64.png"];
        _markImageView.layer.cornerRadius = 20;
        _markImageView.layer.masksToBounds = YES;
        _markImageView.alpha = 1;
    }
    
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
